//
//  LPActivityDetailTableFooterView.m
//  LovingPartyBuilding
//
//  Created by 刘应平 on 2017/6/6.
//  Copyright © 2017年 刘应平. All rights reserved.
//

#import "LPActivityDetailTableFooterView.h"

@implementation LPActivityDetailTableFooterView

/**  60  */
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor themeGrayColor];
        
       
    }
    return self;
}


- (void)setTitles:(NSArray *)titles{
    _titles = titles;
    NSInteger leftIndex;
    if (titles.count == 1) {
        leftIndex = 2;
    }else{
        leftIndex = 4;
    }
    CGFloat left = ([UIScreen zj_screenWith] - 120 * [UIScreen zj_screenWScale] * titles.count) / leftIndex;
    
    
    for (int i = 0; i < titles.count; i ++) {
        UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(left + (left * 2 + 120 * [UIScreen zj_screenWScale]) * i, 12 * [UIScreen zj_screenHScale], 120 * [UIScreen zj_screenWScale], 36 * [UIScreen zj_screenHScale])];
        button.tag = i;
        button.layer.borderWidth = 1;
        button.layer.borderColor = [UIColor themeColor].CGColor;
        button.layer.cornerRadius = 3;
        button.layer.masksToBounds = YES;
        button.titleLabel.font = [UIFont systemFontOfSize:[UIScreen zj_textFontScale] * 15];
        [button setTitle:titles[i] forState:UIControlStateNormal];
        [button setTitleColor:[UIColor themeColor] forState:UIControlStateNormal];
        button.titleLabel.textAlignment = NSTextAlignmentCenter;
        [button addTarget:self action:@selector(clickButton:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:button];
    }
}
- (void)clickButton:(UIButton *)sender{
    if (self.delegate) {
        [self.delegate lpActivityFooter_clickButton_index:sender.tag];
    }
}

@end
